(import (srfi srfi-19))

(simple-format (current-output-port) "date: ~s\n" (current-date))
(simple-format (current-output-port) "date: ~s\n" (make-date 0 0 0 10 13 3 2021 0))
(simple-format (current-output-port) "time: ~s\n" (current-time time-utc))

(define seconds 1)
(define minutes (* 60 seconds))
(define hours (* 60 minutes))

;; calculate time differences / durations
(let ([now (current-time time-utc)])
  (let* ([now+1h
          (add-duration now (make-time time-duration 0 (* 1 hours)))]
         [now+2h30min
          (add-duration
           (add-duration now (make-time time-duration 0 (* 2 hours)))
           (make-time time-duration 0 (* 30 minutes)))]
         [time-diff+1h
          (time-difference now+1h now)]
         [time-diff+2h30min
          (time-difference now+2h30min now)])
    (simple-format (current-output-port) "duration: ~s\n" time-diff+1h)
    (simple-format (current-output-port) "duration in s: ~s\n" (time-second time-diff+1h))
    (simple-format (current-output-port) "duration: ~s\n" time-diff+2h30min)
    (simple-format (current-output-port) "duration in s: ~s\n" (time-second time-diff+2h30min))))

;; Compare dates

(let* ([now (current-time time-utc)]
       [now+1h (add-duration now (make-time time-duration 0 (* 1 hours)))])
  (simple-format (current-output-port) "now <= now+1h: ~s\n" (time<=? now now+1h))
  (simple-format (current-output-port) "now < now+1h: ~s\n" (time<? now now+1h))
  (simple-format (current-output-port) "now = now+1h: ~s\n" (time=? now now+1h))
  (simple-format (current-output-port) "now >= now+1h: ~s\n" (time>=? now now+1h))
  (simple-format (current-output-port) "now > now+1h: ~s\n" (time>? now now+1h)))
